class Student < ActiveRecord::Base
  has_one  :choice

  USER_TYPES = [
    [ "学生", "stu" ],
    [ "教师", "tea" ],
  ].freeze # freeze to make this array constant

  #  学生选择导师操作
  def self.tea_invited(stu_id,tea_id)
    cho = Choice.new
    cho.stu_id = stu_id
    cho.tea_id = tea_id
    cho.stu_status = "同意"
    cho.tea_status = "待定"
    cho.save
  end

  #  学生登录操作
  def student_login(name, password)
    Student.login(name, password)
  end
  def self.login(n, p)
    find(:first, :conditions =>
        ["sname = ? AND spassword = ? ", n, p] )
  end
end
